<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.cqggrw.util.*"%>
<%@ page import="com.cqggrw.domain.*"%>
<%@ page import="com.cqggrw.service.*"%>
<%@ page import="com.cqggrw.service.impl.*"%>
<%
	request.setCharacterEncoding("utf-8");
	response.setContentType("text/html;charset=UTF-8");
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
	+ request.getServerName() + ":" + request.getServerPort()
	+ path + "/";
	
	AdServiceI adService = new AdServiceImpl();
	List<Ad> adList = adService.get();
	Map<Integer, Ad> adMap = new HashMap<Integer, Ad>();
	for(Ad ad : adList) {
		adMap.put(ad.getId(), ad);
	}
%>
<%
	String idStr = request.getParameter("id");
	String CategoryName = null;
	if (idStr != null) {
		Connection conn = null;
		PreparedStatement ps = null;
		ResultSet rs = null;
	
		String sql = "select * from tbl_category where id = ?;";
		try {
	conn = DBUtil.getConn();
	ps = conn.prepareStatement(sql);
	ps.setInt(1, Integer.parseInt(idStr));
	rs = ps.executeQuery();
	if(rs.next()) {
		CategoryName = rs.getString("name");
	}
		} catch (Exception e) {
	e.printStackTrace();
		} finally {
	DBUtil.close(conn, ps, rs);
		}
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>重庆公共人物</title>
<link href="css/common.css" type="text/css" rel="stylesheet" />
<link href="css/channel.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="jslib/jquery-easyui-1.3.1/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="jslib/jquery-easyui-1.3.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="jslib/jquery-easyui-1.3.1/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="jslib/tools.js"></script>
<link rel="stylesheet" href="jslib/jquery-easyui-1.3.1/themes/default/easyui.css" type="text/css"></link>
<link rel="stylesheet" href="jslib/jquery-easyui-1.3.1/themes/icon.css" type="text/css"></link>
</head>
<body>
	<div class="top">
		<div class="top1">
			<div class="logo">
				<h6>焦点热门</h6>
			</div>
			<div class="times">每日小贴士：2012年4月28日</div>
		</div>
		<div class="menu">
			<a target="_blank" href="<%=basePath%>">公共人物首页</a> - <a target="_blank" href="news.jsp?id=13"><font color="#FF0000">焦点</font> </a> - <a target="_blank" href="news.jsp?id=2">关注</a> - <a target="_blank" href="news.jsp?id=4">达人</a> - <a target="_blank" href="news.jsp?id=14">教育</a> - <a target="_blank" href="news.jsp?id=3">精英领导</a> - <a target="_blank" href="news.jsp?id=28">区县</a> - <a target="_blank" href="news.jsp?id=26">观点</a> - <a target="_blank" href="news.jsp?id=2">公共</a> - <a target="_blank" href="news.jsp?id=21">文萃</a> - <a target="_blank" href="news.jsp?id=6">追寻</a> - <a target="_blank" href="news.jsp?id=10">访谈</a> - <a target="_blank" href="news.jsp?id=23">环球</a> - <a target="_blank" href="news.jsp?id=25">体育</a>- <a target="_blank" href="news.jsp?id=29">图说天下</a>
		</div>
	</div>
	<div class="banner">
		<a target="_blank" href="<%=adMap.get(12).getLink()%>"><img src="images/AdImg/<%=adMap.get(12).getImgName()%>" /> </a>
	</div>
	<div class="content3">
		<div class="content3l">
			<div class="recommend">
				<ul class="recom_ul">
					<%
						NewsServiceI<News> service = new NewsServiceImpl();
														List<News> newsList = service.getByTypeId(2);
														int i2 = 1;
														for (News news : newsList) {
															if (i2 > 8)
																break;
					%>
					<li><a target="_blank" href='news/news.jsp?id=<%=news.getId()%>' title='<%=news.getName()%>'><%=news.getName().length() <= 14 ? news.getName() : news
						.getName().substring(0, 14)%></a> <%
 	i2++;
  			 	}
 %>
					
				</ul>
			</div>
			<div class="ad1">
				<a target="_blank" href="<%=adMap.get(22).getLink()%>"><img src="images/AdImg/<%=adMap.get(22).getImgName()%>" /> </a>
			</div>
			<div class="ad1">
				<a target="_blank" href="<%=adMap.get(23).getLink()%>"><img src="images/AdImg/<%=adMap.get(23).getImgName()%>" /> </a>
			</div>
		</div>
		<div class="content3r">
			<ul class="content3r_ul">
				<%
					int pageInt = 1;
							List<News> newsListSea = null;
								int pageSize = 23;
								int pageTotal = 0;
								Utils.log(request.getMethod());
								String name = request.getParameter("name");
							if("GET".equals(request.getMethod())) {
								name = new String(request.getParameter("name").getBytes("ISO-8859-1"),"utf-8");
							}
								new String(request.getParameter("name").getBytes("ISO-8859-1"),"utf-8");
								Utils.log(name);
								if (name != null) {
							String pageStr = request.getParameter("page");
							Utils.log(pageStr);
							if(pageStr != null) {
								pageInt = Integer.parseInt(pageStr);
							}
							
							newsListSea = service.searchByName(name, pageInt);
							pageTotal = service.countForSearch(name);
							for(News news : newsListSea) {
				%>
				<li><span><%=news.getAddDate()%></span><a href="news/news.jsp?id=<%=news.getId()%>"><%=news.getName()%></a></li>
				<%
					}
							pageTotal = service.countForSearch(name);
								}
				%>
			</ul>
			<%
				if(newsListSea.size() != 0) {
			%>
			<div id="pp" style="background:#efefef;border:1px solid #ccc;"></div>
			<%
				} else {
			%>
			<div align="center">
				<font color="red">未搜索到相关记录！</font>
			</div>
			<%
				}
			%>
			<script type="text/javascript">
	$('#pp').pagination({   
	    total:<%=pageTotal%>,   
	    pageSize:<%=pageSize%>,
	    pageNumber:<%=pageInt%>,
	    showRefresh:false,
	    showPageList : false,
	    pageList: [<%=pageSize%>],
	    onSelectPage:function(pageNumber, pageSize){
	    	window.location.href='SearchPage.jsp?name=<%=name%>&page=' + pageNumber;
					}
				});
			</script>
		</div>
	</div>
	<div class="foot">
		<div class="links">
			<span>友情链接：</span>
			<%
				LinkServiceI linkService = new LinkServiceImpl();
				List<Link> links = (ArrayList<Link>) linkService.get();
				for (int i = 0; i < links.size(); i++) {
			%>
			<a target="_blank" href='<%=links.get(i).getUrl()%>'><%=links.get(i).getName()%></a>
			<%
				if (i < links.size() - 1)
						out.print("|");
				}
			%>
		</div>
		<div class="copyright">
			<div class="company">主办单位：重庆行政公共人物杂志社</div>
			<div class="map">
				<a href="about.jsp?id=1">关于我们</a> | <a href="about.jsp?id=2">杂志简介</a> | <a href="about.jsp?id=3">广告刊例</a> | <a href="about.jsp?id=4">组织机构</a> | <a href="about.jsp?id=5">联系我们</a> | <a href="about.jsp?id=6">本网声明</a> | <a href="about.jsp?id=7">版权声明</a>
			</div>
			<p>
				Copyright &copy; 2008-2012 www.cqggrw.com All Rights Reserved 渝ICP备12001034号-1&nbsp;技术支持：<a href="http://www.cqgew.com">重庆政企</a>
		</div>
	</div>
</body>
</html>
